package com.sanpu.kxe.business.main.adapter;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.widget.FrameLayout;

import com.sanpu.kxe.business.main.bean.InviteFriendsOutput;
import com.sanpu.kxe.business.main.fragment.InviteFriendsFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Description：邀请好友viewpager
 * Created by 薛勇军 on 2019/4/23.
 */

public class InviteFriendsPagerAdapter extends FragmentStatePagerAdapter {

    private List<InviteFriendsOutput> mFriendsOutputs = new ArrayList<>();

    private List<InviteFriendsFragment> mFriendsFragment = new ArrayList<>();

    public InviteFriendsPagerAdapter(FragmentManager fm, List<InviteFriendsOutput> friendsOutputs) {
        super(fm);
        if (friendsOutputs != null) {
            mFriendsOutputs.clear();
            mFriendsFragment.clear();
            mFriendsOutputs.addAll(friendsOutputs);
            for (InviteFriendsOutput friendsOutput: friendsOutputs) {
                mFriendsFragment.add(InviteFriendsFragment.getInstance(friendsOutput));
            }
        }
    }

    @Override
    public InviteFriendsFragment getItem(int position) {
        return mFriendsFragment.get(position);
    }

    @Override
    public int getCount() {
        return mFriendsOutputs.size();
    }

    public FrameLayout getShareView(int position) {
        return mFriendsFragment.get(position).getShareViewFl();
    }
}
